package com.cyt.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.cyt.entity.GuanLI;
import com.cyt.util.DBManager;

/**
 * 管理员信息查询 通过账号查
 * @author 喜悦
 *
 */
public class GuanLiDaoImpl {
	public GuanLI getGuanLiName(String zhang ) {
		GuanLI gl=null;
		Statement st = null;
		ResultSet rs = null;
		
		Connection conn = DBManager.getConnection();
		// 2.创建Statement执行对象(用来执行sql语句)
		try {// try 正常执行
			st = conn.createStatement();
			String sql = "SELECT * from guanli WHERE zhanghao='"+zhang+"'";
			rs = st.executeQuery(sql);
			while (rs.next()) {
				int guanId = rs.getInt("guanId");
				String zhanghao = rs.getString("zhanghao");
				String mima = rs.getString("mima");
 			    gl = new GuanLI(guanId, zhanghao, mima);
				
			}
			return gl;

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}

	}
}
